import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '@/views/demo'

Vue.use(VueRouter)

/* 
  路由表配置解释
  component     除了根路径路由是直接赋值一个组件, 其他都应该做路由懒加载
                注: 路由懒加载主要需要注意 webpack 的魔法注释 webpackChunkName, 会根据名字名称去分割chunk
  meta {
    title       项目标题, 动态改变
  }
*/

const routes = [
  {
    path: '/',
    name: 'demo',
    component: Index,
    meta: {
      title: '示例首页'
    }
  },
  {
    path: '/404',
    name: '404',
    component: () => import(/* webpackChunkName: "DefaultPage" */ '@/components/DefaultPage/DefaultPage.vue'),
    meta: {
      title: '404'
    }
  },
  {
    path: '*',
    redirect: '/404'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
